var windowName = "login";
apiready = function(){
    onWindowShow(function () {
        console.log(windowName + " show")
    })
    onWindowHide(function () {
        console.log(windowName + " hide")
    })
    console.log("index page is OK");
    var Page = createVM("#Page",{
        //页面数据
        form:{}
        ,username:""
        ,password:""
        ,usernameRules: [
            { validate: (val) => !!val, message: '必须填写用户名'},
            { validate: (val) => val.length >= 2, message: '用户名长度大于2'}
        ]
        ,passwordRules: [
            { validate: (val) => !!val, message: '必须填写密码'},
            { validate: (val) => val.length >= 3 && val.length <= 24, message: '密码长度大于3小于25'}
        ]
        ,validateForm: {
            username: '',
            password: ''
        }
    },{
        //页面方法
        "init":function () {
        }
        ,"submit":function() {
            this.$refs.form.validate().then((result) => {
                if (result){
                    apiPost("/app/user/login",this.validateForm,function (res) {

                        setLocData("roles",res.data)

                        showToast(res.message)
                        goback();
                    })
                }else{
                    showToast("请检查输入的信息")
                }
            });
        },
    })
    Page.init()

}